Vue.component('dong-show',{
	props:{
		info:{
			type:Object,
			required:true
		},
		open:{
			type:Boolean,
			required:true
		}
	},
	mounted(){
		console.log("info"+this.info)
		console.log("open"+this.open)
	},
	methods:{
		closeFrom() {
			this.open = false;
			this.$emit('type',this.open)
		},
		updateReportInfo(){
			
			var form = document.getElementById('myForm');
			  var formData = new FormData(form);
			
			  // 构造包含名称和值的对象
			  var formObject = {};
			  for (var pair of formData.entries()) {
			    formObject[pair[0]] = pair[1];
			  }
			
			  // 将对象转换为 JSON 字符串
			  var jsonData = JSON.stringify(formObject);
			  
			$.ajax("/doctor/Report/updateReportInfo", {
			    type: "POST",
			    data: {
			        data: jsonData,
			       
			    },
			    success: function(data, textStatus) {
					
			        let datas = JSON.parse(data);
			        if (datas.statusCode == 200) {
			           
			            alert(datas.errMsg);
						location.reload();
			        } else {
			            alert(datas.errMsg)
			        }
			    }
			})
			
		
		}
		
	},
	template:`
	<div class="modal fade show" style="display: block;" v-if="open">
		<div class="modal-dialog modal-lg" id="print">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title">编辑体检项目结果</h5>
					<button type="button" class="btn-close"
						@click="closeFrom()"></button>
				</div>
				<div class="modal-body">
					<form class="comment-form" id="myForm">
						<div class="row">
	
							<div class="col-lg-3">
								<div class="mb-3">
									<label
										class="text-black font-w600 form-label">体检项目
										<span class="required">*</span></label>
									<input type="text" class="form-control" v-model="info.projectName"
										readonly id="project" name="project"
										placeholder="体检项目" >
										<input type="hidden" class="form-control"
											readonly id="id" name="id" :value="info.id"
											placeholder="体检项目" >
								</div>
							</div>
							<div class="col-lg-3">
								<div class="mb-3">
									<label
										class="text-black font-w600 form-label">体检状态
										<span class="required">*</span></label>
									
										<select name="status" v-model="info.status" class="form-control">
											<option value="0" :selected="info.status == 0">待检查</option>
											<option value="1" :selected="info.status == 1">检查中</option>
											<option value="2" :selected="info.status == 2">已检查</option>
										</select>
								</div>
							</div>
						
							<div class="table-responsive" style="text-align: center;">
								<table
									class="table table-striped table-responsive-sm" >
									<thead>
										<tr>
											<th>#</th>
											<th>细项</th>
											<th>参数</th>
										</tr>
									</thead>
									<tbody id="flist">
										<tr v-for="(item,index) in info.targets">
											
											
											<td style="    padding: 0.7375rem 0.625rem;">{{index + 1}}</td>
											<td style="    padding: 0.7375rem 0.625rem;">{{item.targetName}}</td>
											<td style="    padding: 0.7375rem 0.625rem;">
													<input type="text" :name="item.id" :value="item.targetNum" class="form-control"/>
											</td>
											
										</tr>
										
										
									</tbody>
								</table>
							</div>
							<div class="col-lg-12">
								<div class="mb-3">
									<label
										class="text-black font-w600 form-label">科室小结
										<span class="required">*</span></label>
									
										<textarea row=3 class="form-control" name="content" id="content">{{info.subjectContent}}</textarea>
								</div>
							</div>
							
							<div class="col-lg-12 text-center">
								<button type="button" class="btn btn-outline-primary" @click="updateReportInfo()">修改体检</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
		<div class="col-lg-12 text-center">
			<button type="button" class="btn btn-outline-primary"
				@click="print()">打印</button>
		</div>
	</div>
	`
})